package com.ruoyi.web.controller.spoken;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SpokenQa;
import com.ruoyi.system.service.ISpokenQaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "/qa", description = "首页问答模块")
@RequestMapping("/spoken/qa")
@RestController
public class QaController extends BaseController {

    @Autowired
    ISpokenQaService qaService;


    @ApiOperation("问答列表")
    @GetMapping("/list")
    public TableDataInfo list(SpokenQa qa){
        startPage();
        return getDataTable(qaService.selectList(qa));
    }

    @ApiOperation("添加问答")
    @PostMapping
    public AjaxResult add(@RequestBody SpokenQa qa){
        return toAjax(qaService.insert(qa));
    }

    @ApiOperation("修改问答")
    @PutMapping
    public AjaxResult edit(@RequestBody SpokenQa qa){
        return toAjax(qaService.update(qa));
    }

    @ApiOperation("查询问答")
    @GetMapping("/{qaId}")
    public AjaxResult getById(@PathVariable Long qaId){
        return success(qaService.getById(qaId));
    }

    @ApiOperation("删除问答")
    @DeleteMapping("/{qaId}")
    public AjaxResult remove(@PathVariable Long qaId){
        return success(qaService.delete(qaId));
    }

}
